<template>
  <el-breadcrumb separator="/">
    <el-breadcrumb-item
      v-for="item in breadcrumbs"
      :key="item.path"
      :to="item.path"
    >
      {{ item.meta?.title }}
    </el-breadcrumb-item>
  </el-breadcrumb>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import type { RouteLocationMatched } from 'vue-router'

const route = useRoute()

// 生成面包屑数据
const breadcrumbs = computed(() => {
  return route.matched.filter(
    (item: RouteLocationMatched) => item.meta && item.meta.title,
  )
})
</script>

<style scoped>
.el-breadcrumb {
  line-height: 1;
}
</style>
